<!DOCTYPE html>
<html lang="zh-CN" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>花龙腾航 - 我的机票</title>
    <script src="https://cdn.tailwindcss.com"></script>
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
    <style>
        @import url('https://fonts.googleapis.com/css2?family=Noto+Sans+SC:wght@400;500;700&display=swap');

        body {
            font-family: 'Noto Sans SC', sans-serif;
            background-color: #f8fafc;
        }

        .logo-text {
            background: linear-gradient(135deg, #3b82f6, #8b5cf6);
            -webkit-background-clip: text;
            background-clip: text;
            color: transparent;
            font-weight: 700;
        }

        .ticket-card {
            transition: all 0.3s ease;
            box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
            border-radius: 12px;
            overflow: hidden;
        }

        .ticket-card:hover {
            transform: translateY(-2px);
            box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.1);
        }

        .status-badge {
            padding: 0.25rem 0.75rem;
            border-radius: 9999px;
            font-size: 0.75rem;
            font-weight: 600;
        }

        .tab-active {
            position: relative;
            color: #3b82f6;
            font-weight: 600;
        }

        .tab-active:after {
            content: "";
            position: absolute;
            bottom: -1px;
            left: 0;
            width: 100%;
            height: 3px;
            background: #3b82f6;
            border-radius: 3px 3px 0 0;
        }

        .airplane-icon {
            transform: rotate(90deg);
            color: #3b82f6;
        }

        .highlight {
            background-color: #FEF3C7;
            transition: background-color 0.3s;
        }

        .fade-in {
            animation: fadeIn 0.3s ease-in-out;
        }

        @keyframes fadeIn {
            from { opacity: 0; transform: translateY(10px); }
            to { opacity: 1; transform: translateY(0); }
        }

        .ticket-detail {
            max-height: 0;
            overflow: hidden;
            transition: max-height 0.3s ease-out;
        }

        .ticket-detail.open {
            max-height: 500px;
        }

        .progress-bar {
            height: 6px;
            border-radius: 3px;
            background-color: #e5e7eb;
        }

        .progress-fill {
            height: 100%;
            border-radius: 3px;
            background: linear-gradient(90deg, #3b82f6, #8b5cf6);
            transition: width 0.3s ease;
        }

        .date-picker {
            position: relative;
        }

        .date-picker input {
            padding-right: 2.5rem;
        }

        .date-picker i {
            position: absolute;
            right: 1rem;
            top: 50%;
            transform: translateY(-50%);
            pointer-events: none;
            color: #6b7280;
        }

        .search-box {
            position: relative;
        }

        .search-box i {
            position: absolute;
            left: 1rem;
            top: 50%;
            transform: translateY(-50%);
            color: #9ca3af;
        }

        .search-box input {
            padding-left: 2.5rem;
        }

        .user-avatar {
            background: linear-gradient(135deg, #3b82f6, #8b5cf6);
        }
        .dropdown-menu {
            display: none;
            position: absolute;
            right: 0;
            top: 100%;
            background-color: white;
            border-radius: 0.5rem;
            box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
            min-width: 200px;
            z-index: 10;
        }

        .dropdown-menu.open {
            display: block;
        }

        .dropdown-item {
            padding: 0.5rem 1rem;
            cursor: pointer;
            transition: background-color 0.2s;
        }

        .dropdown-item:hover {
            background-color: #f3f4f6;
        }

        .ticket-header {
            background: linear-gradient(135deg, #3b82f6, #8b5cf6);
            color: white;
            padding: 1rem;
        }

        .boarding-pass {
            border: 2px dashed #e5e7eb;
            border-radius: 8px;
            padding: 1rem;
            position: relative;
        }

        .boarding-pass:before {
            content: "";
            position: absolute;
            top: 50%;
            left: 0;
            right: 0;
            height: 2px;
            background: repeating-linear-gradient(to right, #e5e7eb, #e5e7eb 10px, transparent 10px, transparent 20px);
        }

        .seat-number {
            background: #3b82f6;
            color: white;
            border-radius: 4px;
            padding: 0.25rem 0.5rem;
            font-weight: bold;
        }

        .qr-code {
            width: 100px;
            height: 100px;
            background: #f3f4f6;
            display: flex;
            align-items: center;
            justify-content: center;
            border-radius: 8px;
        }
    </style>
</head>
<body>
<!-- Header -->
<header class="bg-white shadow-sm sticky top-0 z-10">
    <div class="container mx-auto px-4 py-4 flex justify-between items-center">
        <div class="flex items-center space-x-2">
            <i class="fas fa-plane text-3xl text-blue-500"></i>
            <h1 class="text-2xl font-bold logo-text">花龙腾航</h1>
        </div>
        <nav class="hidden md:flex space-x-6">
            <a href="user_index" class="text-gray-600 hover:text-blue-500">首页</a>
            <a href="user_flight_search" class="text-gray-600 hover:text-blue-500">航班查询</a>
            <a href="user_order" class="text-gray-600 hover:text-blue-500">我的订单</a>
            <a href="user_ticket" class="text-gray-600 hover:text-blue-500">我的机票</a>
            <a href="user_member_center" class="text-gray-600 hover:text-blue-500">会员中心</a>
        </nav>
        <div class="flex items-center space-x-4">
            <div class="flex items-center space-x-2 cursor-pointer group relative" id="user-menu">
                <div class="w-8 h-8 rounded-full user-avatar overflow-hidden">
                    <img th:if="${imageExists}" th:src="'static/images/'+${user_id}+'.jpg?version=' + ${#dates.createNow().time}" alt="用户头像" class="w-full h-full object-cover">
                    <img th:if="${!imageExists} and ${sex} == '女'" src="https://randomuser.me/api/portraits/women/44.jpg" alt="用户头像" class="w-full h-full object-cover">
                    <img th:if="${!imageExists} and ${sex} == '男'" src="https://randomuser.me/api/portraits/men/71.jpg" alt="用户头像" class="w-full h-full object-cover">
                </div>
                <span class="hidden md:inline text-gray-700 group-hover:text-blue-500" th:text="${name}">张先生</span>
                <div class="dropdown-menu" id="dropdown-menu">
                    <div class="dropdown-item" onclick="location.href='user_profile'">
                        <i class="fas fa-user-cog mr-2"></i> 个人主页
                    </div>
                    <div class="dropdown-item" onclick="location.href='user_account_manage'">
                        <i class="fas fa-cog mr-2"></i> 账号管理
                    </div>
                    <div class="border-t border-gray-200 my-1"></div>
                    <div class="dropdown-item text-red-500" onclick="location.href='user_logout'">
                        <i class="fas fa-sign-out-alt mr-2"></i> 退出登录
                    </div>
                </div>
            </div>
        </div>
    </div>
</header>

<!-- 主要内容 -->
<div class="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8 py-8">
    <div class="flex flex-col md:flex-row gap-8">
        <!-- 侧边栏 -->
        <div class="w-full md:w-64 flex-shrink-0">
            <div class="bg-white rounded-lg shadow-sm overflow-hidden">
                <div class="p-6 bg-indigo-600 text-white text-center">
                    <div class="relative mx-auto w-24 h-24 rounded-full overflow-hidden border-4 border-white mb-4">
                        <img th:if="${imageExists}" th:src="'static/images/'+${user_id}+'.jpg?version=' + ${#dates.createNow().time}" alt="用户头像" class="w-full h-full object-cover">
                        <img th:if="${!imageExists} and ${sex} == '女'" src="https://randomuser.me/api/portraits/women/44.jpg" alt="用户头像" class="w-full h-full object-cover">
                        <img th:if="${!imageExists} and ${sex} == '男'" src="https://randomuser.me/api/portraits/men/71.jpg" alt="用户头像" class="w-full h-full object-cover">
                        <form action="user_upload" method="post" enctype="multipart/form-data">
                            <input type="file" name="photo" accept="image/jpeg, image/png" id="upload-input" class="hidden"
                                   onchange="if (this.files[0].size > 5 * 1024 * 1024) {
                                    alert('文件不能超过 5MB');
                                    return false;}
                                    this.form.submit();">
                            <label for="upload-input" class="absolute bottom-0 right-0 bg-indigo-500 rounded-full p-2 hover:bg-indigo-700 focus:outline-none cursor-pointer">
                                <i class="fas fa-camera text-white text-xs"></i>
                            </label>
                        </form>
                    </div>
                    <h3 class="text-lg font-semibold" th:text="${name}">张美丽</h3>
                    <p class="text-indigo-200 text-sm" th:text="${grade}">金牌会员</p>
                </div>
                <nav class="space-y-1">
                    <a href="user_profile" class="block px-4 py-2 rounded-lg bg-blue-50 text-blue-600 font-medium transition">
                        <i class="fas fa-user mr-3 text-blue-500"></i> 个人资料
                    </a>
                    <a href="user_order" class="block px-4 py-2 rounded-lg text-gray-700 hover:bg-blue-50 hover:text-blue-600 transition">
                        <i class="fas fa-ticket mr-3 text-gray-400"></i> 我的订单
                    </a>
                    <a href="user_ticket" class="block px-4 py-2 rounded-lg text-gray-700 hover:bg-blue-50 hover:text-blue-600 transition">
                        <i class="fas fa-ticket-alt mr-3 text-gray-400"></i> 我的机票
                    </a>
                    <a href="user_member_center" class="block px-4 py-2 rounded-lg text-gray-700 hover:bg-blue-50 hover:text-blue-600 transition">
                        <i class="fas fa-crown mr-3 text-gray-400"></i> 会员权益
                    </a>
                    <a href="user_account_manage" class="block px-4 py-2 rounded-lg text-gray-700 hover:bg-blue-50 hover:text-blue-600 transition">
                        <i class="fas fa-cog mr-3 text-gray-400"></i> 账户设置
                    </a>
                </nav>
            </div>

            <div class="mt-6 bg-white rounded-lg shadow-sm overflow-hidden">
                <div class="p-4 border-b">
                    <h4 class="text-sm font-medium text-gray-700">
                        <i class="fas fa-medal mr-2 text-yellow-500"></i> 会员权益
                    </h4>
                </div>
                <div class="p-4">
                    <div class="flex items-center mb-3">
                        <div class="w-8 h-8 rounded-full bg-indigo-100 flex items-center justify-center mr-3">
                            <i class="fas fa-check text-indigo-600 text-xs"></i>
                        </div>
                        <span class="text-sm text-gray-600">优先值机</span>
                    </div>
                    <div class="flex items-center mb-3">
                        <div class="w-8 h-8 rounded-full bg-indigo-100 flex items-center justify-center mr-3">
                            <i class="fas fa-check text-indigo-600 text-xs"></i>
                        </div>
                        <span class="text-sm text-gray-600">额外行李额</span>
                    </div>
                    <div class="flex items-center">
                        <div class="w-8 h-8 rounded-full bg-indigo-100 flex items-center justify-center mr-3">
                            <i class="fas fa-check text-indigo-600 text-xs"></i>
                        </div>
                        <span class="text-sm text-gray-600">贵宾休息室</span>
                    </div>
                </div>
            </div>
        </div>

        <!-- 主内容区 -->
        <div class="flex-1">
            <div class="bg-white rounded-lg shadow-sm profile-card overflow-hidden">
                <div class="p-6 border-b">
                    <div class="flex justify-between items-center">
                        <h2 class="text-xl font-semibold text-gray-800">
                            <i class="fas fa-user-circle mr-2 text-indigo-600"></i> 个人信息
                            <p th:if="${update_failure}" style="color: red">更新失败！请重新输入</p>
                        </h2>
                    </div>
                </div>

                <!-- 个人信息编辑模式 -->
                <form method="post" action="user_profile_edit">
                    <div id="edit-mode" class="p-6">
                        <form id="profile-form">
                            <div class="grid grid-cols-1 md:grid-cols-2 gap-6">
                                <div>
                                    <label for="edit-name" class="block text-sm font-medium text-gray-700 mb-1">姓名</label>
                                    <input type="text" id="edit-name" class="input-field w-full px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:border-indigo-500" th:value="${name}" name="rename">
                                </div>
                                <div>
                                    <label class="block text-sm font-medium text-gray-700 mb-1">性别</label>
                                    <div class="px-3 py-2 bg-gray-100 rounded-md text-gray-800" th:text="${sex}"></div>
                                </div>
                                <div>
                                    <label for="edit-birthday" class="block text-sm font-medium text-gray-700 mb-1">出生日期</label>
                                    <input type="date" id="edit-birthday" class="input-field w-full px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:border-indigo-500" th:value="${birthday}">
                                </div>
                                <div>
                                    <label class="block text-sm font-medium text-gray-700 mb-1">会员等级</label>
                                    <div class="px-3 py-2 bg-gray-100 rounded-md text-gray-800" th:text="${grade}">金牌会员</div>
                                </div>
                                <div>
                                    <label for="edit-account" class="block text-sm font-medium text-gray-700 mb-1">账号</label>
                                    <div class="relative">
                                        <input type="text" id="edit-account" class="input-field w-full px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:border-indigo-500" th:value="${account}" name="reaccount">
                                        <p th:if="${account_failure}" style="color: red">该账号已注册！请重新输入</p>
                                        <!--button type="button" class="absolute right-2 top-2 text-xs text-indigo-600 hover:text-indigo-800">验证</button-->
                                    </div>
                                </div>
                                <div>
                                    <label for="edit-phone" class="block text-sm font-medium text-gray-700 mb-1">手机号码</label>
                                    <div class="relative">
                                        <input type="tel" id="edit-phone" class="input-field w-full px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:border-indigo-500" th:value="${phone_number}" name="rephone">
                                        <p th:if="${phone_failure}" style="color: red">该号码已注册！请查看是否输入错误</p>
                                        <!--button type="button" class="absolute right-2 top-2 text-xs text-indigo-600 hover:text-indigo-800">验证</button-->
                                    </div>
                                </div>
                                <div>
                                    <label class="block text-sm font-medium text-gray-700 mb-1">证件类型</label>
                                    <!--select id="edit-id-type" class="input-field w-full px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:border-indigo-500">
                                        <option value="id-card" selected>身份证</option>
                                        <option value="passport">护照</option>
                                        <option value="hk-macau-pass">港澳通行证</option>
                                        <option value="tw-pass">台湾通行证</option>
                                    </select-->
                                    <div class="px-3 py-2 bg-gray-100 rounded-md text-gray-800" th:text="${ID_type}"></div>
                                </div>
                                <div>
                                    <label class="block text-sm font-medium text-gray-700 mb-1">证件号码</label>
                                    <div class="px-3 py-2 bg-gray-100 rounded-md text-gray-800" th:text="${ID_card}"></div>
                                </div>
                                <div class="md:col-span-2">
                                    <label class="block text-sm font-medium text-gray-700 mb-1">邮箱地址</label>
                                    <div class="px-3 py-2 bg-gray-100 rounded-md text-gray-800" th:text="${email == null or email == ''} ? '暂无邮箱信息': ${email}"></div>
                                </div>
                                <div>
                                    <label for="edit-city" class="block text-sm font-medium text-gray-700 mb-1">常用城市</label>
                                    <div class="relative">
                                        <input type="text" id="edit-city" class="input-field w-full px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:border-indigo-500" th:value="${city}" name="recity">
                                    </div>
                                </div>
                            </div>
                            <input type="hidden" th:value="${ID_card}" name="olIDcard">
                            <input type="hidden" th:value="${account}" name="olAccount">
                            <input type="hidden" th:value="${password}" name="olPassword">
                            <input type="hidden" th:value="${phone_number}" name="olPhone">
                            <input type="hidden" th:value="${sex}" name="olSex">
                            <input type="hidden" th:value="${city}" name="olCity">
                            <div class="mt-8 flex justify-end space-x-3">
                                <button type="button" id="cancel-edit-btn" class="px-4 py-2 border border-gray-300 rounded-md text-sm font-medium text-gray-700 hover:bg-gray-50 focus:outline-none focus:ring-2 focus:ring-indigo-500">
                                    取消
                                </button>
                                <button type="submit" class="px-4 py-2 bg-indigo-600 text-white rounded-md text-sm font-medium hover:bg-indigo-700 focus:outline-none focus:ring-2 focus:ring-indigo-500">
                                    保存更改
                                </button>
                            </div>
                        </form>
                    </div>
                </form>
            </div>
        </div>
    </div>
</div>

<!-- Footer -->
<footer class="bg-gray-50 mt-12">
    <div class="container mx-auto px-4 py-8">
        <div class="grid grid-cols-1 md:grid-cols-4 gap-8">
            <div>
                <div class="flex items-center space-x-2 mb-4">
                    <i class="fas fa-plane text-2xl text-blue-500"></i>
                    <h3 class="text-xl font-bold logo-text">花龙腾航</h3>
                </div>
                <p class="text-gray-600 text-sm">花龙腾航，让您的每一次飞行都成为美好回忆。我们致力于提供安全、舒适、便捷的航空服务。</p>
            </div>
            <div>
                <h4 class="font-bold text-gray-800 mb-4">关于我们</h4>
                <ul class="space-y-2 text-sm text-gray-600">
                    <li><a href="public_company_profile" class="hover:text-blue-500 transition">公司简介</a></li>
                    <li><a href="public_company_profile" class="hover:text-blue-500 transition">企业文化</a></li>
                    <li><a href="public_company_profile" class="hover:text-blue-500 transition">发展历程</a></li>
                    <li><a href="public_job_posting" class="hover:text-blue-500 transition">招贤纳士</a></li>
                </ul>
            </div>
            <div>
                <h4 class="font-bold text-gray-800 mb-4">帮助中心</h4>
                <ul class="space-y-2 text-sm text-gray-600">
                    <li><a href="public_faq" class="hover:text-blue-500 transition">常见问题</a></li>
                    <li><a href="public_baggage_regulations" class="hover:text-blue-500 transition">行李规定</a></li>
                    <li><a href="public_company_profile" class="hover:text-blue-500 transition">航班动态</a></li>
                    <li><a href="public_callus" class="hover:text-blue-500 transition">联系客服</a></li>
                </ul>
            </div>
            <div>
                <h4 class="font-bold text-gray-800 mb-4">联系我们</h4>
                <ul class="space-y-2 text-sm text-gray-600">
                    <li class="flex items-center"><i class="fas fa-phone-alt mr-2 text-blue-500"></i> 客服热线: 19976338635</li>
                    <li class="flex items-center"><i class="fas fa-envelope mr-2 text-blue-500"></i> ganshenghao888@qq.com</li>
                    <li class="flex items-center"><i class="fas fa-map-marker-alt mr-2 text-blue-500"></i> 广东省广州市天河区华南农业大学</li>
                </ul>
                <div class="flex space-x-4 mt-4">
                    <a href="https://weixin.com" class="h-8 w-8 rounded-full bg-blue-100 flex items-center justify-center text-blue-500 hover:bg-blue-200 transition">
                        <i class="fab fa-weixin"></i>
                    </a>
                    <a href="https://weibo.com" class="h-8 w-8 rounded-full bg-blue-100 flex items-center justify-center text-blue-500 hover:bg-blue-200 transition">
                        <i class="fab fa-weibo"></i>
                    </a>
                    <a href="https://qq.com" class="h-8 w-8 rounded-full bg-blue-100 flex items-center justify-center text-blue-500 hover:bg-blue-200 transition">
                        <i class="fab fa-qq"></i>
                    </a>
                </div>
            </div>
        </div>
        <div class="border-t border-gray-200 mt-8 pt-6 text-center text-sm text-gray-500">
            <p>© 2025 花龙腾航航空公司 版权所有 | 京ICP备12345678号</p>
        </div>
    </div>
</footer>

<div class="fixed bottom-8 right-8 z-50">
    <button onclick="toggleChat()" class="bg-blue-500 text-white p-4 rounded-full shadow-lg hover:bg-blue-600">
        <i class="fas fa-comment-dots text-2xl"></i>
    </button>

    <div id="chat-window" class="hidden fixed bottom-24 right-8 w-96 bg-white rounded-lg shadow-xl">
        <div class="bg-blue-500 text-white p-4 rounded-t-lg flex justify-between">
            <h3 class="font-bold">智能客服</h3>
            <button onclick="toggleChat()" class="hover:text-blue-200">
                <i class="fas fa-times"></i>
            </button>
        </div>
        <div class="h-96 p-4 overflow-y-auto" id="chat-messages">
            <div class="text-gray-500 text-sm">您好！请问需要什么帮助？</div>
        </div>
        <form id="chat-form" onsubmit="sendMessage(this, event)" class="border-t p-4">
            <div class="flex gap-2">
                <label>
                    <input type="text" id="message-input" name="message"
                           class="flex-1 border rounded-lg p-2"
                           placeholder="输入问题..."
                           required
                           maxlength="200">
                </label>
                <button type="submit" class="bg-blue-500 text-white px-4 py-2 rounded-lg">
                    <i class="fas fa-paper-plane"></i>
                </button>
            </div>
        </form>
    </div>
</div>

<script>
    // 编辑个人信息切换
    document.getElementById('cancel-edit-btn').addEventListener('click', function() {
        window.location.href = 'user_profile';
    });
</script>
<script>
    document.addEventListener('DOMContentLoaded', function() {
        // 用户菜单功能
        const userMenu = document.getElementById('user-menu');
        const dropdownMenu = document.getElementById('dropdown-menu');

        userMenu.addEventListener('click', (event) => {
            event.stopPropagation();
            dropdownMenu.classList.toggle('open');
        });

        document.addEventListener('click', (event) => {
            const isClickInside = userMenu.contains(event.target) || dropdownMenu.contains(event.target);
            if (!isClickInside) {
                dropdownMenu.classList.remove('open');
            }
        });

        // 聊天功能
        const chatWindow = document.getElementById('chat-window');
        const chatForm = document.getElementById('chat-form');
        let isSending = false;

        window.toggleChat = function() {
            chatWindow.classList.toggle('hidden');
            if (!chatWindow.classList.contains('hidden')) {
                document.getElementById('chat-messages').scrollTop = document.getElementById('chat-messages').scrollHeight;
            }
        };

        window.sendMessage = async function(form, event) {
            event.preventDefault();

            if (isSending) return false;
            isSending = true;

            const input = document.getElementById('message-input');
            const message = input.value.trim();

            console.log('发送的消息:', message);

            if (!message) {
                alert("请输入有效内容");
                isSending = false;
                return false;
            }

            try {
                addMessage('user', message);
                input.value = '';
                const loader = addMessage('assistant', '<div class="dot-pulse"></div>');

                const contextPath = window.location.pathname.split('/')[1];
                const response = await fetch(`/${contextPath}/ChatServlet`, {
                    method: 'POST',
                    headers: {
                        'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'
                    },
                    body: `message=${encodeURIComponent(message)}`
                });

                if (!response.ok) {
                    throw new Error(`HTTP错误! 状态码: ${response.status}`);
                }

                const data = await response.text();
                loader.remove();
                addMessage('assistant', data);
            } catch (error) {
                console.error('请求失败:', error);
                addMessage('assistant', `服务暂时不可用（${error.message}）`);
                alert(`请求失败: ${error.message}`);
            } finally {
                isSending = false;
            }
            return false;
        };

        function addMessage(role, content) {
            console.log("添加消息 - 角色:", role, "内容:", content);
            const container = document.getElementById('chat-messages');
            const div = document.createElement('div');
            div.className = `mb-4 flex ${role === 'user' ? 'justify-end' : 'justify-start'}`;

            const contentDiv = document.createElement('div');
            contentDiv.className = role === 'user'
                ? 'bg-blue-500 text-white rounded-lg p-3 max-w-[80%]'
                : 'bg-gray-100 text-gray-800 rounded-lg p-3 max-w-[80%]';

            contentDiv.innerHTML = content;
            div.appendChild(contentDiv);
            container.appendChild(div);

            container.scrollTo({
                top: container.scrollHeight,
                behavior: 'smooth'
            });

            return div;
        };

        document.getElementById('message-input').addEventListener('keypress', (e) => {
            if (e.key === 'Enter' && !e.shiftKey) {
                e.preventDefault();
                chatForm.requestSubmit();
            }
        });
    });
</script>
</body>
</html>